import { showToast } from "vant";
import { isEmpty ,parseTime} from "@/utils/utils";
export const formatPriority = (priority) => {
  if (priority === "1") {
    return "急";
  } else if (priority === "2") {
    return "核";
  } else if (priority === "3") {
    return "催";
  } else {
    return "";
  }
};

export const formatTime = (time) => {
  if (time == null || time === "") {
    return "";
  }
  // let date = new Date(time);
  // return formatDate(date; 'yyyy-MM-dd hh:mm')
  return time;
};

export const formatTimeYear = (time) => {
  if (time == null || time === "") {
    return "";
  }
  // let date = new Date(time);
  // return formatDate(date; 'yyyy-MM-dd')
  return time;
};

export const handlingFormFormat = (handlingForm) => {
  if (0 == handlingForm) {
    return "转送单";
  } else if (1 == handlingForm) {
    return "督办单";
  }
};

export const levelFormat = (level) => {
  if (0 == level) {
    return "紧急";
  } else if (1 == level) {
    return "普通";
  } else if (2 == level) {
    return "次紧急";
  } else {
    return "";
  }
};

//是否催单
export const priorityFormat = (priority) => {
  if (3 == priority) {
    return "是";
  } else {
    return "否";
  }
};




//先行联系
export const isContactFormat = (isContact) => {
  if (0 == isContact) {
    return "已联";
  } else {
    return "未联";
  }
};

//未联原因
export const noContactReasonFormat = (noContactReason) => {
  if (1 == noContactReason) {
    return '始终未连';
  }else if (2 == noContactReason) {
    return '始终关机';
  }else{
    return '其他';
  }
};

//现场查看
export const onsiteFormat = (param) => {
  if (0 == param) {
    return "";
  } else if (1 == param) {
    return "是";
  } else if (2 == param) {
    return "否";
  } else if (3 == param) {
    return "无实际现场";
  }
};

//是否核单
export const priorityFormat2 = (priority) => {
  if (2 == priority) {
    return "是";
  } else {
    return "否";
  }
};

//工单来源格式化
export const sourceFormat = (source) => {
  if (0 == source) {
    return "网站";
  } else if (1 == source) {
    return "电话";
  } else if (2 == source) {
    return "手机";
  } else if (3 == source) {
    return "传真";
  } else if (4 == source) {
    return "微信";
  } else if (5 == source) {
    return "信件";
  } else if (6 == source) {
    return "政务大厅";
  } else if (7 == source) {
    return "热线发起";
  } else if (8 == source) {
    return "双向通道";
  } else if (9 == source) {
    return "管理办公室发起";
  } else if (10 == source) {
    return "其他";
  } else if (11 == source) {
    return "手语";
  } else if (12 == source) {
    return "中国上海门户网站";
  } else if (13 == source) {
    return "语音留言";
  } else if (14 == source) {
    return "国家政务服务投诉";
  } else if (16 == source) {
    return "随申办";
  } else if (18 == source) {
    return "随申拍";
  } else if (20 == source) {
    return "中国政府网";
  } else if (15 == source) {
    return "在线帮办";
  } else if (22 == source) {
    return "国家政务服务平台";
  } else if (24 == source) {
    return "春节返乡路";
  } else if (26 == source) {
    return "企业云";
  } else if (28 == source) {
    return "支付宝";
  }
};


//布尔值格式化
export const booleanFormat = (param) => {
  if (0 == param) {
    return "是";
  } else if (1 == param) {
    return "否";
  }  else {
    return "";
  }
};
//是否满意格式化
export const isStatisFied = (param) => {
  if (0 == param) {
    return "";
  } else if (1 == param) {
    return "满意";
  } else if (2 == param) {
    return "不满意";
  } else if (3 == param) {
    return "认可";
  } else if (4 == param) {
    return "未评价";
  }
};
//是否解决格式化
export const isSolveFormat = (param) => {
  if (0 == param) {
    return "";
  } else if (1 == param) {
    return "实际解决";
  } else if (2 == param) {
    return "解释说明";
  } else if (3 == param) {
    return "诉求过高";
  } else if (4 == param) {
    return "参考备案";
  } else if (5 == param) {
    return "未解决";
  }
};
//答复方式格式化
export const replyMethod = (param) => {
  if (0 == param) {
    return "";
  } else if (1 == param) {
    return "电话";
  } else if (2 == param) {
    return "书面";
  } else if (3 == param) {
    return "约谈";
  }
};
//事实认定格式化
export const factFindingFormat = (param) => {
  if (0 == param) {
    return "";
  } else if (1 == param) {
    return "属实";
  } else if (2 == param) {
    return "部分属实";
  } else if (3 == param) {
    return "不属实";
  } else if (4 == param) {
    return "无政策信息";
  } else if (5 == param) {
    return "有政策信息";
  } else if (6 == param) {
    return "对政策解释不接受";
  } else if (7 == param) {
    return "留作参考";
  } else if (8 == param) {
    return "不予采纳";
  } else if (9 == param) {
    return "部分采纳";
  } else if (10 == param) {
    return "采纳";
  } else {
    return "";
  }
};
//审核状态
export const statusFormat = (status) => {
  if (9 == status) {
    return "处理";
  } else if (11 == status) {
    return "延期申请";
  } else if (13 == status) {
    return "退单申请";
  } else {
    return "处理";
  }
};

//申请状态
export const appleStatusFormat = (param) => {
  if (param == 5) {
    //二级工单待审
    return '待审核'
  } else if (param == 14) {
    // 三级已审核，二级待审
    return '待审核'
  } else if (param == 16) {
    //二级已审核，一级审核中
    return '审核成功'
  } else {
    return ''
  }
}
export const filterSatisfied = (type) => {
  if (type === "1") {
    return "满意";
  } else if (type === "2") {
    return "不满意";
  } else if (type === "3") {
    return "认可";
  } else if (type === "4") {
    return "未评价";
  } else {
    return "";
  }
};
export const filterSove = (type) => {
  if (type === "1") {
    return "实际解决";
  } else if (type === "2") {
    return "解释说明";
  } else if (type === "3") {
    return "诉求过高";
  } else if (type === "4") {
    return "参考备案";
  } else if (type === "5") {
    return "未解决";
  } else {
    return "";
  }
};
export const filterCustomerType = (type) => {
  if (type === "1") {
    return "个人";
  } else if (type === "2") {
    return "企业";
  } else {
    return "";
  }
};

export const filterServiceType = (type) => {
  if (type === "1") {
    return "综合服务";
  } else if (type === "2") {
    return "一网通办";
  } else {
    return "";
  }
};

//申请天数格式化
export const formatDelayPeriod = (delayPeriod) => {
  if (1 == delayPeriod) {
    return "15个自然日";
  } else if (2 == delayPeriod) {
    return "30个自然日";
  } else if (3 == delayPeriod) {
    return "60个自然日";
  } else if (4 == delayPeriod) {
    return "90个自然日";
  } else {
    return "";
  }
};

//审核结果
export const findingOfAuditFormat = (findingOfAudit) => {
  if (1 == findingOfAudit) {
    return "同意";
  } else if (2 == findingOfAudit) {
    return "不同意";
  } else {
    return "";
  }
};

//申请原因
export const applyReasonFormat = (applyReason) => {
  if (1 == applyReason) {
    return "法定时限";
  } else if (2 == applyReason) {
    return "特殊疑难";
  } else {
    return "";
  }
};
//申请状态格式化
export const formatStatus = (type) => {
  if (11 == type) {
    return "待本部门审核";
  } else if (12 == type) {
    return "申请成功";
  } else {
    return "";
  }
};

//诉求定义格式化
export const formatAppeal = (type) => {
  if (1 == type) {
    return "诉求合理合法";
  } else if (2 == type) {
    return "无政策依据";
  }else if (3 == type) {
    return "诉求过高";
  } else if (4 == type) {
    return "其它";
  } else if (5 == type) {
    return "无需认定";
  } else {
    return "";
  }
};

//退单状态格式化
export const formatBackStatus = (type) => {
  if (13 == type) {
    return "待审核";
  } else if (14 == type) {
    return "审核成功";
  } else {
    return "";
  }
};
//工单状态
export const formatOrderStatus = (type) => {
  // if (1 == type) {
  //   return "待办";
  // } else if (2 == type) {
  //   return "催单";
  // } else if (3 == type) {
  //   return "回访单";
  // } else {
  //   return "";
  // }
  if (type == 10) {
    return "审核成功"
  } else {
    return "未审核"
  }
};



 //申请状态格式化
 export const appleFormatStatus = (type) => {
  if (11 == type) {
    return '待本部门审核';
  } else if (12 == type) {
    return '申请成功';
  }else  {
    return '';
  }
};

//延时到期日方法
export function delayPeriodChange(sele,limit){
  let date= new Date(Date.parse(limit.replace(/-/g,   "/")));
  let time = new Date(Date.parse(limit.replace(/-/g,   "/")));
  if(sele === 1){
    time.setDate(date.getDate()+15);
  }else if(sele === 2){
    time.setDate(date.getDate()+30);
  }else if(sele === 3){
    time.setDate(date.getDate()+60);
  }else if(sele === 4){
    time.setDate(date.getDate()+90);
  }
  return parseTime(time);
  
};

//必填项校验
export const varityFormResult = (list) => {
  try {
    if (Array.isArray(list)) {
      list.forEach(subList => {
        subList.forEach(element => {
          if (element.isRequired && (isEmpty(element.content) || element.content.length == 0)) {
            const msg = "请输入" + element.title
            throw new Error(msg);
          } 
        })
      });
    }
  } catch(e) {
    const msg = e.message;
    showToast(msg);
    return false
  }
  
  return true
}

//时间格式转换
export const formartCreateTime = (list) => {
  if (Array.isArray(list)) {
    return list.join("-");
  }

  return ""

}





